﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fastyou.WCF.Contracts;
using System.ServiceModel;
using System.Threading;

namespace Fastyou.WCF.ServiceLib
{
    [ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Single,InstanceContextMode=InstanceContextMode.PerCall)]
    public class ConSingleMode:ISingleMode
    {
        #region ISingleMode Members

        public void Add(int x, int y)
        {
            Console.WriteLine("session id is {0}\r\n", OperationContext.Current.SessionId.ToString());
            Console.WriteLine("Add b time is {0}\r\n", DateTime.Now.ToLongTimeString());
            Console.WriteLine("the add params is {0} and {1}\r\n", x.ToString(), y.ToString());
            
            Thread.Sleep(1000 * 5);
            Console.WriteLine("Add e time is {0}\r\n", DateTime.Now.ToLongTimeString());
        }

        public void Sub(int x, int y)
        {
            Console.WriteLine("session id is {0}\r\n", OperationContext.Current.SessionId.ToString());
            Console.WriteLine("Sub time is {0}\r\n", DateTime.Now.ToLongTimeString());
            Console.WriteLine("the sub params is {0} and {1}\r\n", x.ToString(), y.ToString());
            Thread.Sleep(1000 * 5);
        }

        #endregion
    }
}
